package org.example.controller;

import org.example.model.ChatMessage;
import org.example.service.ChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/chat")
public class ChatController {
    @Autowired
    private ChatMessageService chatMessageService;
    
    @GetMapping("/history/{username}")
    public List<ChatMessage> getHistoryMessages(@PathVariable String username) {
        return chatMessageService.getHistoryMessages(username);
    }
}